package pl.com.like.sequoia.model.bio.enums;

/**
 * Enum used for setting type of returning file.
 * @author Pawel Wolanski
 *
 */
public enum FileTypeEnum {

	GENBANK("gb", "G"), FASTA("fasta", "F"), GENPEPT("gp", "T"), PDB("pdb", "P"), PDB_ZIP("pdb.gz", "PZ"), PDB_HEAD("pdb?headerOnly=YES", "PH");

	private String rettype;
	private String dbType;

	
	public String toDbValue() {
		return dbType;
	}

	/**
	 * set raw type of returning file
	 * @param rettype
	 */
	private FileTypeEnum(String rettype, String dbType) {
		this.rettype = rettype;
		this.dbType = dbType;
	}

	/**
	 * get raw type of returning file. That value is needed add to entrez's URL. 
	 * @return raw type of returning file
	 */
	public String getRetType() {
		return this.rettype;
	}
	
	public FileTypeEnum fromDbValue(String dbValue) {
		for (FileTypeEnum value : values()) {
			if (value.dbType.equals(dbValue))
				return value;
		}
		return defaultValue();
	}

	
	public static FileTypeEnum defaultValue() {
		return FileTypeEnum.GENBANK;
	}
}
